<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: D:/Projects/MiXiM/extsrc/mixim/src/modules/mac/CSMAMacLayer.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00430.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">CSMAMacLayer.h</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef CSMAMAC_LAYER_H</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define CSMAMAC_LAYER_H</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &lt;list&gt;</span>
<a name="l00005"></a>00005 
<a name="l00006"></a>00006 <span class="preprocessor">#include &quot;MiXiMDefs.h&quot;</span>
<a name="l00007"></a>00007 <span class="preprocessor">#include &quot;BaseMacLayer.h&quot;</span>
<a name="l00008"></a>00008 
<a name="l00047"></a><a class="code" href="a00069.html">00047</a> <span class="keyword">class </span>MIXIM_API <a class="code" href="a00069.html" title="MAC module which provides non-persistent CSMA.">CSMAMacLayer</a> : <span class="keyword">public</span> <a class="code" href="a00026.html" title="A very simple MAC module template which provides de- and encapsulation of messages using the standard...">BaseMacLayer</a>
<a name="l00048"></a>00048 {
<a name="l00049"></a>00049   <span class="keyword">private</span>:
<a name="l00052"></a>00052   <a class="code" href="a00069.html" title="MAC module which provides non-persistent CSMA.">CSMAMacLayer</a>(<span class="keyword">const</span> <a class="code" href="a00069.html" title="MAC module which provides non-persistent CSMA.">CSMAMacLayer</a>&amp;);
<a name="l00055"></a>00055   <a class="code" href="a00069.html" title="MAC module which provides non-persistent CSMA.">CSMAMacLayer</a>&amp; <a class="code" href="a00026.html#aac78343ae4c96940669323e51ec09ada" title="Assignment operator is not allowed.">operator=</a>(<span class="keyword">const</span> <a class="code" href="a00069.html" title="MAC module which provides non-persistent CSMA.">CSMAMacLayer</a>&amp;);
<a name="l00056"></a>00056 
<a name="l00057"></a>00057   <span class="keyword">public</span>:
<a name="l00058"></a>00058   <a class="code" href="a00069.html" title="MAC module which provides non-persistent CSMA.">CSMAMacLayer</a>()
<a name="l00059"></a>00059     : <a class="code" href="a00026.html" title="A very simple MAC module template which provides de- and encapsulation of messages using the standard...">BaseMacLayer</a>()
<a name="l00060"></a>00060     , macState(RX)
<a name="l00061"></a>00061     , slotDuration(0)
<a name="l00062"></a>00062     , difs(0)
<a name="l00063"></a>00063     , macQueue()
<a name="l00064"></a>00064     , queueLength(0)
<a name="l00065"></a>00065     , backoffTimer(NULL)
<a name="l00066"></a>00066     , minorMsg(NULL)
<a name="l00067"></a>00067     , txAttempts(0)
<a name="l00068"></a>00068     , maxTxAttempts(0)
<a name="l00069"></a>00069     , bitrate(0)
<a name="l00070"></a>00070     , txPower(0)
<a name="l00071"></a>00071     , initialCW(0)
<a name="l00072"></a>00072     , nbBackoffs(0)
<a name="l00073"></a>00073     , backoffValues(0)
<a name="l00074"></a>00074     , nbTxFrames(0)
<a name="l00075"></a>00075   {}
<a name="l00076"></a>00076   <span class="keyword">virtual</span> ~<a class="code" href="a00069.html" title="MAC module which provides non-persistent CSMA.">CSMAMacLayer</a>();
<a name="l00077"></a>00077 
<a name="l00078"></a>00078   <span class="keyword">protected</span>:
<a name="l00080"></a><a class="code" href="a00069.html#af397ee30d94486721632bbcdad8274d1">00080</a>     <span class="keyword">typedef</span> std::list&lt;cPacket*&gt; <a class="code" href="a00069.html#af397ee30d94486721632bbcdad8274d1" title="Type for a queue of cPackets.">MacQueue</a>;
<a name="l00081"></a>00081 
<a name="l00088"></a><a class="code" href="a00069.html#aa504ef94f12cc702c82a81f5f0654913">00088</a>     <span class="keyword">enum</span> <a class="code" href="a00069.html#aa504ef94f12cc702c82a81f5f0654913" title="MAC states.">States</a> {
<a name="l00090"></a><a class="code" href="a00069.html#aa504ef94f12cc702c82a81f5f0654913ab8f2c7ef825f0c569512139f5482e631">00090</a>         <a class="code" href="a00069.html#aa504ef94f12cc702c82a81f5f0654913ab8f2c7ef825f0c569512139f5482e631" title="MAC accepts packets from PHY layer.">RX</a>,
<a name="l00092"></a><a class="code" href="a00069.html#aa504ef94f12cc702c82a81f5f0654913acd80830b40d6cc8615ea4ff537cb37ca">00092</a>         <a class="code" href="a00069.html#aa504ef94f12cc702c82a81f5f0654913acd80830b40d6cc8615ea4ff537cb37ca" title="Clear Channel Assessment - MAC checks whether medium is busy.">CCA</a>,
<a name="l00094"></a><a class="code" href="a00069.html#aa504ef94f12cc702c82a81f5f0654913a18461bd2358689c90c3c5cade629e0b0">00094</a>         <a class="code" href="a00069.html#aa504ef94f12cc702c82a81f5f0654913a18461bd2358689c90c3c5cade629e0b0" title="MAC transmits a packet.">TX</a>,
<a name="l00095"></a>00095     };
<a name="l00096"></a>00096 
<a name="l00098"></a><a class="code" href="a00069.html#aa78817d8e3bbf7850e5d84a6377ea907">00098</a>     <a class="code" href="a00069.html#aa504ef94f12cc702c82a81f5f0654913" title="MAC states.">States</a> <a class="code" href="a00069.html#aa78817d8e3bbf7850e5d84a6377ea907" title="kepp track of MAC state">macState</a>;
<a name="l00099"></a>00099 
<a name="l00107"></a><a class="code" href="a00069.html#a420bec99b62f029c75996930bc5cb56f">00107</a>     <span class="keywordtype">double</span> <a class="code" href="a00069.html#a420bec99b62f029c75996930bc5cb56f" title="Duration of a slot.">slotDuration</a>;
<a name="l00108"></a>00108 
<a name="l00114"></a><a class="code" href="a00069.html#a5a0fde63ac12cccfdb98bfe6314ce46d">00114</a>     <span class="keywordtype">double</span> <a class="code" href="a00069.html#a5a0fde63ac12cccfdb98bfe6314ce46d" title="Maximum time between a packet and its ACK.">difs</a>;
<a name="l00115"></a>00115 
<a name="l00118"></a><a class="code" href="a00069.html#a9869bd7667eacdb3a9c5f8ecb0c3ed19">00118</a>     <a class="code" href="a00069.html#af397ee30d94486721632bbcdad8274d1" title="Type for a queue of cPackets.">MacQueue</a> <a class="code" href="a00069.html#a9869bd7667eacdb3a9c5f8ecb0c3ed19" title="A queue to store packets from upper layer in case another packet is still waiting for transmission...">macQueue</a>;
<a name="l00119"></a>00119 
<a name="l00121"></a><a class="code" href="a00069.html#a27628021750dc0e8cf651382663276b8">00121</a>     <span class="keywordtype">unsigned</span> <a class="code" href="a00069.html#a27628021750dc0e8cf651382663276b8" title="length of the queue">queueLength</a>;
<a name="l00122"></a>00122 
<a name="l00124"></a><a class="code" href="a00069.html#a946e29bb8fead33566797a7062649a1e">00124</a>     cMessage* <a class="code" href="a00069.html#a946e29bb8fead33566797a7062649a1e" title="Timer for backoff (non-persistent CSMA)">backoffTimer</a>;
<a name="l00125"></a>00125 
<a name="l00131"></a><a class="code" href="a00069.html#af06855c96a26dbe77937062bead7f82c">00131</a>     cMessage* <a class="code" href="a00069.html#af06855c96a26dbe77937062bead7f82c" title="Multi-purpose message.">minorMsg</a>;
<a name="l00132"></a>00132 
<a name="l00139"></a><a class="code" href="a00069.html#a6c9b1b0f5eeb45db611633ca986f537b">00139</a>     <span class="keywordtype">unsigned</span> <a class="code" href="a00069.html#a6c9b1b0f5eeb45db611633ca986f537b" title="count the number of tx attempts">txAttempts</a>;
<a name="l00140"></a>00140 
<a name="l00145"></a><a class="code" href="a00069.html#ae3aa6dae3903cabacbcafe783ef33d91">00145</a>     <span class="keywordtype">unsigned</span> <a class="code" href="a00069.html#ae3aa6dae3903cabacbcafe783ef33d91" title="maximum number of transmission attempts">maxTxAttempts</a>;
<a name="l00146"></a>00146 
<a name="l00148"></a><a class="code" href="a00069.html#a70ae938b76fa8fe65d97b0b511767894">00148</a>     <span class="keywordtype">double</span> <a class="code" href="a00069.html#a70ae938b76fa8fe65d97b0b511767894" title="the bit rate at which we transmit">bitrate</a>;
<a name="l00149"></a>00149 
<a name="l00151"></a><a class="code" href="a00069.html#a619cc05568e8ebef57ff9c551cd311d0">00151</a>     <span class="keywordtype">double</span> <a class="code" href="a00069.html#a619cc05568e8ebef57ff9c551cd311d0" title="The power at which we transmit.">txPower</a>;
<a name="l00152"></a>00152 
<a name="l00154"></a><a class="code" href="a00069.html#a8ec2aea0983e2149d3c7d1c06637dd70">00154</a>     <span class="keywordtype">unsigned</span> <a class="code" href="a00069.html#a8ec2aea0983e2149d3c7d1c06637dd70" title="initial contention window size">initialCW</a>;
<a name="l00155"></a>00155 
<a name="l00157"></a><a class="code" href="a00069.html#ae768a2dadff7e2e41a5ecae37bcedc2d">00157</a>     <span class="keywordtype">double</span> <a class="code" href="a00069.html#ae768a2dadff7e2e41a5ecae37bcedc2d" title="Counts the total number of backoffs.">nbBackoffs</a>;
<a name="l00158"></a>00158 
<a name="l00160"></a><a class="code" href="a00069.html#ace6a061501b4d12d2380a458ea253ef5">00160</a>     <span class="keywordtype">double</span> <a class="code" href="a00069.html#ace6a061501b4d12d2380a458ea253ef5" title="Counts the total time spent in backoff.">backoffValues</a>;
<a name="l00161"></a>00161 
<a name="l00163"></a><a class="code" href="a00069.html#a4e15b3f78a53218321cbc408f1cb600b">00163</a>     <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="a00069.html#a4e15b3f78a53218321cbc408f1cb600b" title="Counts the number of frames transmitted.">nbTxFrames</a>;
<a name="l00164"></a>00164 
<a name="l00166"></a>00166     <span class="comment">//DroppedPacket droppedPacket;</span>
<a name="l00167"></a>00167 
<a name="l00169"></a>00169     <span class="comment">//int catDroppedPacket;</span>
<a name="l00170"></a>00170 
<a name="l00172"></a>00172     <span class="comment">//int nicId;</span>
<a name="l00173"></a>00173 
<a name="l00174"></a>00174 <span class="keyword">protected</span>:
<a name="l00176"></a>00176     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00026.html#a61c82dc3b225eac37f7fa9936c28c2c3" title="Initialization of the module and some variables.">initialize</a>(<span class="keywordtype">int</span>);
<a name="l00177"></a>00177 
<a name="l00179"></a>00179     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00025.html#a5ab11502dbeeea89693d29841376a2f7" title="Called when the simulation has finished.">finish</a>();
<a name="l00180"></a>00180 
<a name="l00182"></a>00182     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00026.html#a413375cec02b990a521b62086a02264c">handleLowerMsg</a>(cMessage*);
<a name="l00183"></a>00183 
<a name="l00185"></a>00185     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00026.html#a6de2ca07018de313a7147a03e6d77bff" title="Handle messages comming from the network layer.">handleUpperMsg</a>(cMessage*);
<a name="l00186"></a>00186 
<a name="l00188"></a>00188     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00026.html#add5277c1a60dab10db40c8d9641e48c4" title="Handle self messages such as timer...">handleSelfMsg</a>(cMessage*);
<a name="l00189"></a>00189 
<a name="l00191"></a>00191     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00026.html#a796d456d593dfab3188b37e506dd76a8" title="Handle control messages from lower layer.">handleLowerControl</a>(cMessage *msg);
<a name="l00192"></a>00192 
<a name="l00202"></a>00202     <span class="keyword">virtual</span> <span class="keywordtype">void</span> scheduleBackoff();
<a name="l00203"></a>00203 
<a name="l00207"></a>00207     <span class="keyword">virtual</span> macpkt_ptr_t <a class="code" href="a00026.html#a0e1c8dad62e40f43a43c7b8a0cb71501" title="Encapsulate the NetwPkt into an MacPkt.">encapsMsg</a>(cPacket* pkt);
<a name="l00208"></a>00208 };
<a name="l00209"></a>00209 
<a name="l00210"></a>00210 <span class="preprocessor">#endif</span>
<a name="l00211"></a>00211 <span class="preprocessor"></span>
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><b>CSMAMacLayer.h</b>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:30 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
